﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;

namespace Atosenet.IO
{
    public abstract class IOParameter
    {
        #region 成员

        public const string CATEGORY_NAME = "IO设置";

        public event EventHandler ParameterChanged;

        private int _readTimeout = -1;
        private int _writeTimetout = -1;

        #endregion


        #region 初始化

        public IOParameter()
        { }

        #endregion


        #region 事件

        protected void OnParameterChanged()
        {
            if (ParameterChanged != null)
                ParameterChanged(this, EventArgs.Empty);
        }
        
        #endregion


        #region 属性

        [CategoryAttribute(CATEGORY_NAME)]
        [DescriptionAttribute("IO读取超时")]
        public int ReadTimeout
        {
            get { return _readTimeout; }
            set 
            {
                if (_readTimeout != value)
                {
                    _readTimeout = value;
                    OnParameterChanged();
                }
            }
        }

        [CategoryAttribute(CATEGORY_NAME)]
        [DescriptionAttribute("IO写入超时")]
        public int WriteTimeout
        {
            get { return _writeTimetout; }
            set
            {
                if (_writeTimetout != value)
                {
                    _writeTimetout = value;
                    OnParameterChanged();
                }
            }
        }

        public abstract string IOName
        {
            get;
        }

        #endregion
    }


    public enum IOModeType
    {
        None = 0x00,
        Client = 0x01,
        Server = 0x02
    }
}
